﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using memo;
using System.Collections.Generic;

namespace memoTest
{
    [TestClass]
    public class MockDataAccessorTest
    {
        /// <summary>
        /// 
        /// </summary>
        private IDataAccessor myDataAccessor;

        /// <summary>
        /// 
        /// </summary>
        public MockDataAccessorTest()
        {
            Environment.SetEnvironmentVariable("DataAccessorTestMode", "True");
            myDataAccessor = DataAccessorFactory.Get();
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void MockDataAccessorSaveAndLoadTest()
        {
            List<Topic> expectedTopic = CreateTopic();
            myDataAccessor.Save(expectedTopic);
            List<Topic> actualTopic = myDataAccessor.Load();
            Assert.AreEqual<List<Topic>>(expectedTopic, actualTopic, "Az ellenőrzésnél a Topicok nem egyeznek meg.");
        }

        // Negatív teszt!!!!!!!

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private List<Topic> CreateTopic()
        {
            List<Topic> myTopic = new List<Topic>();
            for (int i = 0; i <= 5; i++)
            {
                myTopic.Add(new Topic("Title" + i, "Short description" + i));
            }
            return myTopic;
        }
    }
}
